home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / handson / supercede / Knowodys / APPLETS / CONTTUT / LETTERS.TXT
Encoding:
Text File  |  1996-04-03  |  1.1 KB  |  48 lines

  1. import java.awt.*;
  2. import java.awt.image.*;
  3. import java.applet.Applet;
  4.  
  5. public class Letters extends Applet {
  6. // This applet demonstrates a "continue" statement
  7.  
  8.     char key;
  9.     int keyNumber = (int)'A';
  10.     int row = 0;
  11.     int column = 5;
  12.     int space = 20;
  13.     int lines = 0;
  14.  
  15.      public void init () {
  16.                 setFont(new Font("TimesRoman", Font.BOLD,12));
  17.      }
  18.  
  19.     public void paint (Graphics g) {
  20.  
  21.     
  22.                 Loop: for (int i = 0; i < 255; i++){  // Loop is a statement label
  23.         key = (char)i;
  24.  
  25.         // If the character is not a letter or a digit, return to the loop
  26.         if(!Character.isDigit(key) &&!Character.isLowerCase(key) && !Character.isUpperCase(key) )
  27.                                     continue Loop;  // continue with a statment label
  28.  
  29.         row++;
  30.         lines++;
  31.         if (lines == 25){
  32.             lines = 0;
  33.             column = column + 60;
  34.             row = 0;
  35.         } 
  36.  
  37.                           g.drawString (String.valueOf(key + " = "), column, 12*row);
  38.                            g.drawString (Integer.toString(keyNumber), column + space, 12*row);
  39.                          keyNumber++;
  40.     }         
  41.  
  42. }
  43.  
  44.     
  45. }    
  46.  
  47.  
  48.